import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { NestExpressApplication } from '@nestjs/platform-express';

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule)
  app.useStaticAssets('uploads', {
    prefix: '/uploads',
  }); //配置静态文件托管

  //允许跨域请求
  app.enableCors();
  const options = new DocumentBuilder()
  .setTitle('nest前端API')
  .setDescription('供网站和APP调用的服务端API')
  .setVersion('1.0')
  .addTag('cats')
  .addBearerAuth()
  .build();

  const document = SwaggerModule.createDocument(app, options);
  SwaggerModule.setup('api-docs', app, document);
  await app.listen(3008);
  console.log(`http://localhost:3008/api-docs`)
}
bootstrap();
